package com.zeng.diy;

import org.junit.Test;

/**
 * @author zeng
 * @data 2021/06/10 18:40
 */
public class DiyPoint {
    public void before(){
        System.out.println("使用了aa");
    }
    public void after(){
        System.out.println("使用了bb");
    }
    public int searchInsert(int[] nums, int target) {
        int left = 0;
        int right = nums.length - 1;
        int mid = 0;
        while(left <= right){
            mid = (left + right) / 2;
            if(nums[mid] == target){
                return mid;
            }else if(nums[mid] > target){
                right = mid + 1;
            }else{
                left = mid + 1;
            }
        }
        return mid + 1;

    }
    @Test
    public void test(){
        int[] nums = {1, 3, 5, 4};
        System.out.println(searchInsert(nums, 5));
    }
}
